<template>
  <div>
    <!-- 查询插件 -->
        <!-- 查询插件 -->
   

    <!-- stu展示插件 -->
    <div>
      <el-table :data="pageBean.beanList" border style="width: 100%">
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column prop="logid" label="操作人员id"></el-table-column>
        <el-table-column prop="username" label="名字"></el-table-column>
        <el-table-column prop="hostip" label="操作主机ip"></el-table-column>
        <el-table-column prop="module" label="模块"></el-table-column>
        <el-table-column prop="content" label="操纵描述"></el-table-column>
        <el-table-column prop="operatortime" label="操作时间"></el-table-column>

        <el-table-column label="操作">
          <template slot-scope="scope">
            <!-- <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button> -->
            <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <!-- 分页插件 -->
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageBean.pageIndex"
        :page-sizes="[3, 4, 5, 6,10,15]"
        :page-size="pageBean.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pageBean.totalRecord"
      ></el-pagination>
    </div>


  <!-- 添加故障的模态框 -->
     





    <!-- 模态框插件 -->
    
    
  </div>
</template>


<script>
//导入axios
import axios from "axios";

export default {
  data() {
    return {
      // tableData: [],
      pageIndex: 1,
      pageSize: 10,
      pageBean: {
        beanList: [],
        pageIndex: 0,
        pageSize: 0,
        totalRecord: 0,
        totalPage: 0
      },
      role: [],
      dept: [],
      // RentCarInfotwo: [],
      // parking: [],
      // rentcarType: [],
      rules: {
        // storeid: [
        //   { required: true, message: '请输入活动名称', trigger: 'blur' },
        //   { min: 1, max: 10, message: '长度在 1 到 10个字符', trigger: 'blur' }
        // ],
        //  operation_state: [
        //   { required: true, message: '请输年龄', trigger: 'blur' },
        //   { min: 1, max: 10, message: '长度在 1 到 10个字符', trigger: 'blur' }
        // ],
        rentcarprice: [
          { required: true, message: "请输年龄", trigger: "blur" },
          { min: 1, max: 10, message: "长度在 1 到 10个字符", trigger: "blur" }
        ]
        //  car_typeid: [
        //   { required: true, message: '请输年龄', trigger: 'blur' },
        //   { min: 1, max: 10, message: '长度在 1 到 10个字符', trigger: 'blur' }
        // ],
        // car_numbe: [
        //   { required: true, message: '请输年龄', trigger: 'blur' },
        //   { min: 1, max: 10, message: '长度在 1 到 10个字符', trigger: 'blur' }
        // ],
        // mailbox_capacity: [
        //   { required: true, message: '请输年龄', trigger: 'blur' },
        //   { min: 1, max: 10, message: '长度在 1 到 10个字符', trigger: 'blur' }
        // ],
        //  seating: [
        //   { required: true, message: '请输年龄', trigger: 'blur' },
        //   { min: 1, max: 10, message: '长度在 1 到 10个字符', trigger: 'blur' }
        // ],
        //  carkm: [
        //   { required: true, message: '请输年龄', trigger: 'blur' },
        //   { min: 1, max: 10, message: '长度在 1 到 10个字符', trigger: 'blur' }
        // ],
      },
      queryParams: {
        rid: "",
        area: "",
        username:"",
        telephone: "",
        did: "",
        status: "",
        starttime: "",
        endtime: ""
      },
      eitParams: {
        username: "",
        password: "",
        rid: "",
        area: "",
        telephone: "",
        hiredate: "",
       status: "",
       did: ""
      },
      AddParams: {
        warn_cause: "",
        rentcarid: "",
        warn_time: "",
        process_state:"",
        empid:"",
      },
      dialogFormVisible: false,
      dialogFormVisibletwo:false,
      title: ""
    };
  },
  created() {
    //生命周期方法
     this.getstaffList();
    // this.getrole();
    // this.getdept();
    // 
  },
  methods: {
   
    updatestu(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          if (valid) {
            if (this.title == "编辑") {
              this.$axios
                .put("http://localhost:8601/staff/updateStaff", this.eitParams)
                .then(resp => {
                  
                  if(resp.data.code==500){
                this.$message("你没有操作权限");
              }else{
                 this.$message("修改成功");
              }
                  
                  this.dialogFormVisible = false;
                   this.getstaffList();
                });
            } else {
              this.$axios
                .post("http://localhost:8601/staff/addStaff", this.eitParams)
                .then(resp => {
                   if(resp.data.code==500){
                this.$message("你没有操作权限");
              }else{
                this.$message("添加成功");
              }
                  
                  this.dialogFormVisible = false;
                  this.getstaffList();
                });
            }
          } else {
            console.log("error submit!!");
            return false;
          }

          //     this.$axios.put("http://localhost:8080/updateRenrCarIn/", this.eitParams).
          //  then(resp=>{
          //   this.$message("修改成功");
          //   this.dialogFormVisible=false;
          //   this.getStudents();
          //  });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    handAddWarn(){
       this.dialogFormVisibletwo = true;
        this.AddParams = { ...row };
    },
    handleEdit(index, row) {
      console.log(index, row);
     
      this.dialogFormVisible = true;
      // this.getStudents();
      this.eitParams = { ...row };
      this.eitParams.did=row.dept.deptname;
      //  this.eitParams.parkid=row.parking.parkname;
      //  this.eitParams.car_typeid=row.rentCarType.cartype_name;
      this.title = "编辑";
    },
    handleDelete(index, row) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$axios
            .delete("http://localhost:8601/staff/dellog/" + row.logid)
            .then(resp => {
              console.log(resp.data);
              if(resp.data.code==500){
                this.$message("你没有操作权限");
              }else{
                 this.$message("删除成功");
              }
              this.getstaffList();
            });
          // this.$message({
          //   type: "success",
          //   message: "删除成功!"
          // });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    

   getstaffList() {
      this.$axios
        .get("http://localhost:8601/staff/getAllStaffLog", {
          params: {
            pageIndex: this.pageIndex,
            pageSize: this.pageSize,
          //  rid: this.queryParams.rid,
          //  area: this.queryParams.area,
          //  telephone: this.queryParams.telephone,
          //  did:this.queryParams.did,
          // //  status:this.queryParams.status,
          //  starttime:this.queryParams.starttime,
          //  endtime: this.queryParams.endtime,
          //  username:this.queryParams.username


         
            // carnumber: this.form.carnumber,
            // area: this.form.area,
            // parktype: this.form.parktype,
            // parkname: this.form.parkname,
            // warn_cause:this.form.warn_cause,
            // rentcarid:this.form.rentcarid,
            // empid:this.form.empid,
            // starttime:this.form.starttime,
            // endtime:this.form.endtime,
          }
        })
        .then(resp => {
          console.log(resp.data)
          if(resp.data.code==500){
               this.$router.push('/');
          }else{
            this.pageBean = resp.data.data;
          }
          
          
        });
    },
    searchStudent() {
      this.getstaffList();
    },
    switchChange(data){
       this.$axios
            .put("http://localhost:8080/updateRenrCarInbyrentcarid/" + data.rentcarid)
            .then(resp => {
              console.log("修改成功");
              this.getstaffList();
            });
          this.$message({
            type: "success",
            message: "修改成功!"
          });
    },
    RentCarAdd() {
      (this.title = "新增"), (this.dialogFormVisible = true);
      // this.$axios
      //   .get("http://localhost:8080/getRentCarType/")
      //   .then(resp => {
      //     console.log(resp);
      //   });
      //  this.$router.push("RentCarAdd");
      //  this.title="新增",
      //  this.dialogFormVisible=true
    },
    closeDialog() {
      console.log("模态框关闭");
      this.eitParams = {};
      this.$refs["eitParams"].clearValidate();
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pageSize = val;
      this.getstaffList();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pageIndex = val;
      this.getstaffList();
    }
  }
};
</script>

<style>
</style>
